package JdkDateDemo4;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeFormatterDemo {
    public static void main(String[] args) {
        /*
            static DateTimeFormatter ofPattern(格式)    获取格式对象
            String format(时间对象)                    按照指定方式格式化
        */
        //获取格式对象
        DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss EE a");
        //获取时间对象
        ZonedDateTime time= Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(dtf1.format(time));
    }
}
